package leetcode春季个人赛;

public class one {
		public static void main(String []args) {
			int []gem = {3,1,2};
			int [][]operations = {{0,2},{2,1},{2,0}};
			System.out.println(solution(gem,operations));
		}
		public static int solution(int gem[],int [][]operations) {
			int max = Integer.MIN_VALUE;
			int min = Integer.MAX_VALUE;
			for(int i = 0; i < operations.length;i++) {
				int []arr = operations[i];
				int temp = gem[arr[0]] >> 1;
				gem[arr[0]] -= temp; 
				gem[arr[1]] += temp;
			}
			for(int i = 0 ; i < gem.length;i++) {
				if(gem[i] > max) {
					max = gem[i];
				}
				if(gem[i] < min) {
					min = gem[i];
				}
			}
			
			return max -  min;
			
			
		}
}
